home *** CD-ROM | disk | FTP | other *** search
- Path: bcfreenet.seflin.lib.fl.us!bcfreenet!z007400b
- From: z007400b@bcfreenet.seflin.lib.fl.us (Ralph Silverman)
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
- Subject: Re: Avoiding typedefs (was: Hungarian notation)
- Followup-To: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
- Date: 30 Jan 1996 18:52:55 GMT
- Organization: SEFLIN Free-Net - Broward
- Message-ID: <4elpe7$h9u@bcfreenet.seflin.lib.fl.us>
- References: <30C40F77.53B5@swsbbs.com> <4bd <4cc2b2$11jq@navajo.gate.net> <DLM3no.4M6@irvine.com>
- NNTP-Posting-Host: bcfreenet.seflin.lib.fl.us
- X-Newsreader: TIN [version 1.2 PL2]
-
- Adam Beneschan (adam@irvine.com) wrote:
- : Douglas Evan Cook <cookd@cs.byu.edu> writes:
-
- : > On 21 Jan 1996, Kazimir Kylheku wrote:
- : >
- : > > I say, don't bother. I avoid typedefs like the plague, even for structures. I
- : > > much rather write the longer form.
- : > >
- : > > void myfunction(struct whatever *x);
- : > >
- : > > Using excessive typedefs will just occlude your code. What is the point of
- : > > having a separate type for MSEC? Later, when someone sees a declaration of a
- : > > variable of type MSEC, he will have to go hunting and pecking for the
- : > > definition of MSEC. It _obviously_ stands for milliseconds, but what the hell
- : > > is it?
-
- : If MSEC obviously stands for milliseconds, then the answer to the
- : question "what the heck is it" is "Milliseconds". If you care at that
- : point how "milliseconds" is implemented, you need to go back and
- : relearn about "abstraction" and why it's important.
-
- : I'll grant that this isn't all that helpful in C, which doesn't
- : contain a whole lot of support for abstract data types; so you pretty
- : much *do* have to know what type of variable it is if you're going to
- : use it. In C++ or Ada83 or Ada95 or UCSD Pascal or Modula or Eiffel,
- : which do provide constructs allow you to define all the operations on
- : a type in one place so you don't have to worry about it later, calling
- : things by abstract type names without worrying about how they're
- : implemented is an absolute MUST. (By the way, in response to an
- : earlier post, THIS is the reason for having named types in those
- : languages---NOT lazy compiler implementors.)
-
- : > The way I was taught, you use typedefs only for variables that are likely
- : > to change type (and you want to change all of the instances of that type
- : > at once) and for cross-platform portability (in a multi-language
- : > environment like Windows or when you are saving data to disk). Using it
- : > for most other things will, as you said, only hamper coding and debugging
- : > efforts. However, to use those examples to induce "typedefs are useless"
- : > is jumping to a bad conclusion. If you want to argue that the uses that
- : > I gave are bad, we can do that, but to generalize without looking at all
- : > potential uses isn't a good idea.
- :
- : I must be missing something. How does
-
- : void myfunction (Whatever *x);
-
- : (where Whatever is a typedef) "occlude your code" or "hamper coding
- : and debugging efforts", while
-
- : void myfunction (struct whatever *x);
-
- : doesn't? The second example looks just like the first, in that you're
- : declaring a variable using some name that I'd have to go somewhere
- : else and look up if I wanted to see how it was implemented. The only
- : difference is a keyword.
-
- : Or does the character sequence "struct" have some magical properties
- : that cause occlusion to break up and everything to become clear?
-
- : -- Adam
-
- --
- *********begin r.s. response***********
-
- traditionally,
- typedef
- is used to "cut out"
- the names of
- 'non-user defined' datatypes
- in source...
-
- the reason, and justification,
- for this,
- traditional,
- use
- are much the same as with
- #define
- constants
- .
-
-
- *********end r.s. response*************
- Ralph Silverman
- z007400b@bcfreenet.seflin.lib.fl.us
-
-